<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "gky_profile".
 *
 * @property integer $user_id
 * @property string $name
 * @property string $public_email
 * @property string $gravatar_email
 * @property string $gravatar_id
 * @property integer $location
 * @property string $website
 * @property string $bio
 * @property string $qyh_user_id
 * @property string $graduate_school
 * @property string $xueli
 * @property string $xuewei
 * @property string $address
 * @property string $tel
 *
 * @property GkyUser $user
 * @property GkyQyhUser $qyh_user
 */
class GkyProfile extends \yii\db\ActiveRecord {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'gky_profile';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['qyh_user_id'], 'safe'],
            [['user_id'], 'required'],
            [['user_id', 'location'], 'integer'],
            [['bio'], 'string'],
            [['name', 'public_email', 'gravatar_email', 'website', 'graduate_school', 'xueli', 'xuewei', 'address', 'tel'], 'string', 'max' => 255],
            [['gravatar_id'], 'string', 'max' => 32],
            [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => GkyUser::className(), 'targetAttribute' => ['user_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'user_id' => 'User ID',
            'name' => '姓名',
//            'public_email' => 'Public Email',
            'gravatar_email' => '注册邮箱',
//            'gravatar_id' => 'Gravatar ID',
            'location' => '所在部门',
//            'website' => 'Website',
//            'bio' => 'Bio',
            'qyh_user_id' => '企业微信号',
            'graduate_school' => '毕业院校',
            'xueli' => '学历',
            'xuewei' => '学位',
            'address' => '家庭住址',
            'tel' => '电话',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser() {
        return $this->hasOne(GkyUser::className(), ['id' => 'user_id']);
    }

    public function getQyhUser() {
        return $this->hasOne(\app\models\GkyQyhUser::className(), ['id' => 'qyh_user_id']);
    }

}
